package org.van.carfimodulesadmin.service.log;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.van.carfimodulessales.dao.LogDao;
import org.van.carfimodulessales.model.LogDomain;

import java.util.List;

@Service
public class LogServiceImpl implements LogService {

    @Autowired
    private LogDao logDao;

    @Override
    public void addLog(String laction, String ldata, String lip, Integer uid) {
        LogDomain logDomain = new LogDomain();
        logDomain.setUid(uid);
        logDomain.setLip(lip);
        logDomain.setLdata(ldata);
        logDomain.setLaction(laction);
        logDao.addLog(logDomain);
    }

    @Override
    public PageInfo<LogDomain> getLogs(int pageNum, int pageSize) {
        PageHelper.startPage(pageNum, pageSize);
        List<LogDomain> logs = logDao.getLogs();
        PageInfo<LogDomain> pageInfo = new PageInfo<>(logs);
        return pageInfo;

    }
}
